package cn.jinjimi.app.reader;

import android.content.Context;
import android.view.View;

import cn.jinjimi.app.R;
import cn.jinjimi.app.reader.holder.ArticleFourHolder;
import cn.jinjimi.app.reader.holder.ArticleHolder;
import cn.jinjimi.app.reader.holder.ArticleSearchHolder;
import cn.jinjimi.app.reader.holder.JinjuHolder;
import cn.jinjimi.app.main.widget.CommonRV.BaseHolder;
import cn.jinjimi.app.main.widget.CommonRV.HolderType;
import cn.jinjimi.app.main.widget.CommonRV.NoMoreHolder;
import cn.jinjimi.app.main.widget.CommonRV.NullHolder;


/**
 * Created by lforxeverc on 2017/4/14.
 */

public class ReaderHolderFactory {
    public static final int TYPE_NULL = 0;
    public static final int TYPE_ARTICLE = 1;
    public static final int TYPE_FOUR_ARTICLE = 2;
    public static final int TYPE_JINJU = 3;
    public static final int TYPE_SEARCH = 4;

    public static <H extends BaseHolder> H create(Context context, int viewType) {
        switch (viewType) {
            case TYPE_ARTICLE:
                return (H) new ArticleHolder(BaseHolder.createView(context, R.layout.item_article), context, TYPE_ARTICLE);
            case TYPE_JINJU:
                return (H) new JinjuHolder(BaseHolder.createView(context, R.layout.item_reader_jinju), context, TYPE_JINJU);
            case TYPE_SEARCH:
                return (H) new ArticleSearchHolder(BaseHolder.createView(context, R.layout.item_article_search), context, TYPE_SEARCH);
            case TYPE_FOUR_ARTICLE:
                return (H) new ArticleFourHolder(BaseHolder.createView(context, R.layout.item_article_four), context, TYPE_FOUR_ARTICLE);
            case HolderType.TYPE_NO_MORE:
                return (H) new NoMoreHolder(BaseHolder.createView(context, R.layout.item_wenba_nomore), context, HolderType.TYPE_NO_MORE);
            default:
                return (H) new NullHolder(new View(context), context, TYPE_NULL);
        }
    }
}
